var tabName_xxSetting = "#message";
var tabName_dbSetting = "#todo";

function submitcssxx() {
    var updatedate = "";
    $(".css-xx-01").each(
        function (j, f) {
            for (var i = 0; i < f.children.length; i++) {
                var checkedstr = f.children[i].children[0].children[0];

                if (checkedstr.checked == true) {
                    updatedate += checkedstr.value + "@" + checkedstr.name;
                    updatedate += ":";
                }
            }

        });
    $(".css-xx-02").each(
        function (j, f) {
            for (var i = 0; i < f.children.length; i++) {
                var checkedstr = f.children[i].children[0].children[0];

                if (checkedstr.checked == true) {
                    updatedate += checkedstr.value + "@" + checkedstr.name;
                    updatedate += ":";
                }
            }

        });
    updatedate = updatedate.substring(0, updatedate.length - 1);
    $.ajax({
        url: MESSAGE_SERVICE_URL + "perMesTypeController/submitCheckbox?type=2",
        type: "POST",
        dataType: "json",
        data: {key: updatedate},
        success: function (r) {
        	if('SUCCESS'==r.status){
        		showMsg('success', r.body);
        	}else{
        		showMsg('warn', r.body);
        	}

        },
        error: function (httpRequest) {
            //alert("提交未知异常！");
            showMsg('warn', "提交未知异常");
        }
    });
}


function submitcssdb() {
    var updatedate = "";
    $(".css-db-01").each(
        function (j, f) {
            for (var i = 0; i < f.children.length; i++) {
                var checkedstr = f.children[i].children[0].children[0];

                if (checkedstr.checked == true) {
                    updatedate += checkedstr.value + "@" + checkedstr.name;
                    updatedate += ":";
                }
            }

        });
    $(".css-db-02").each(
        function (j, f) {
            for (var i = 0; i < f.children.length; i++) {
                var checkedstr = f.children[i].children[0].children[0];

                if (checkedstr.checked == true) {
                    updatedate += checkedstr.value + "@" + checkedstr.name;
                    updatedate += ":";
                }
            }

        });
    updatedate = updatedate.substring(0, updatedate.length - 1);
    $.ajax({
        url: MESSAGE_SERVICE_URL + "perMesTypeController/submitCheckbox?type=1",
        type: "POST",
        dataType: "json",
        data: {key: updatedate},
        success: function (r) {
            if('SUCCESS'==r.status){
            	showMsg('success', r.body);
        	}else{
        		showMsg('warn', r.body);
        	}
        },
        error: function (httpRequest) {
            //alert("提交未知异常！");
            showMsg('warn', "提交未知异常");
        }
    });
}

function submitcssall() {
    var strhref = $(".systemsetsm .tab-bar .active a").attr("href");
    if (strhref == tabName_xxSetting) {
        submitcssxx();
    } else if (strhref == tabName_dbSetting) {
        submitcssdb();
    }

}

$(function () {
	function show(){
		$.post(MESSAGE_SERVICE_URL + "treeMessageController/queryTreeMessage", {key: "2"}, function (rs) {
	        $.bigcss(rs);
	    }, "json");
	}
	setInterval(show,300000);
});
